{$CLEO .qa}
{$USE CLEO+}
{$USE newOpcodes}
{$USE ini}

0000: NOP

script_name "CsPeds"

// By ArtemQa146

// 20@ ped - 10@ render
// 21@ ped - 11@ render
// 22@ ped - 12@ render
// 23@ ped - 13@ render
// 24@ ped - 14@ render
// 25@ ped - 15@ render
// 26@ ped - 16@ render

const
    Peds_Find = 19@
    Ped_Skin = 1@
    Ped_Select = 17@
    Bit_sets = 31@
    Select_Hand = 1
    Number_Peds = 6
    iBuffer = 18@
    Pause_Time = 300
    Minus_Pause = 200
    Pause = 1000
end

0085: iBuffer = 0@ // (int)
0@ = -1


while true
wait 100
if
    Player.Defined($PLAYER_CHAR)
then

gosub @Ped_20
gosub @Realese_animation
    if
        not $ACTIVE_INTERIOR == 0
    then
        gosub @References_remove
        continue
    end

0842: 2@ = player $PLAYER_CHAR town_number
0D59: get_current_weather_to 1@
if and
    not 1@ == 8 // not weather rain
    not 1@ == 16 // not weather rain 2
    2@ == 0
then
    if or
    856D: not actor 20@ defined
    856D: not actor 21@ defined
    856D: not actor 22@ defined
    856D: not actor 23@ defined
    856D: not actor 24@ defined
    856D: not actor 25@ defined
    856D: not actor 26@ defined
then
    Peds_Find = 0
    while 0EA7: get_any_char_no_save_recursive Peds_Find progress_to Peds_Find char_to 0@
    4@ = 50.0
    if 82CB:   not actor 0@ bounding_sphere_visible
    then 4@ = 15.0
    end
    if and
        not 1@ == 9 // ped damaged
        80DF: not actor 0@ driving
        not is_char_script_controlled 0@
        not locate_char_distance_to_char 0@ char $PLAYER_ACTOR radius 4@
        locate_char_distance_to_char 0@ char $PLAYER_ACTOR radius 90.0
    then
        0470: 3@ = actor 0@ current_weapon
        0EFF: get_char_simplest_active_task 0@ id_to 1@ pointer_to 2@
        if and
            3@ == 0 //unarmed
            1@ == 900 //walk
            not Actor.Animation(0@) == "sprint_panic"
            not Actor.Animation(0@) == "woman_runpanic"
            not Actor.Animation(0@) == "idle_chat"
        then
            089F: get_actor 0@ pedtype_to 1@
            if or
                1@ == 4 //man
                1@ == 5 //woman
            then
                gosub @Ped_skin
                if
                    Ped_Skin == true
                then
                    gosub @Load_animation
                    if
                        056D: actor 0@ defined
                    then
                        if
                            not is_char_script_controlled 0@
                        then

                            for Ped_Select = 0 to Number_Peds step 1
                                if
                                    856D: not actor 20@(Ped_Select,1i) defined
                                then
                                    089F: get_actor 0@ pedtype_to 1@
                                    0E40: get_current_hour 2@

                                    if and
                                        Ped_Select == 0 //   
                                        1@ == 4 //man
                                        0E4D: random_percent 10
                                    then
                                        0085: 20@(Ped_Select,1i) = 0@ // (int)
                                        0E0B: mark_char_as_needed 20@(Ped_Select,1i)

                                        // ,   
                                        0209: 3@ = random_int_in_ranges 1 3
                                        if 3@ == 1
                                        then 3@ = 24
                                        else 3@ = 34
                                        end

                                        gosub @Man_Case
                                        gosub @Ped_case
                                        wait Pause
                                        break
                                    end

                                    if and
                                        Ped_Select <= 2 //   
                                        Ped_Select >= 1 //   
                                        2@ >= 6
                                        2@ < 20
                                        0E4D: random_percent 70
                                        1@ == 5 //woman
                                    then
                                        0085: 20@(Ped_Select,1i) = 0@ // (int)
                                        0E0B: mark_char_as_needed 20@(Ped_Select,1i)

                                        // ,   
                                        0209: 3@ = random_int_in_ranges 1 3
                                        if 3@ == 1
                                        then 3@ = 24
                                        else 3@ = 34
                                        end

                                        gosub @Woman_shop
                                        gosub @Ped_case
                                        wait Pause
                                        break
                                    end

                                    if and
                                        Ped_Select == 3 //     
                                        2@ >= 6
                                        2@ < 20
                                        0E4D: random_percent 35
                                        1@ == 5 //woman
                                    then
                                        0085: 20@(Ped_Select,1i) = 0@ // (int)
                                        0E0B: mark_char_as_needed 20@(Ped_Select,1i)
                                        gosub @Tors
                                        if 1@ == 2663
                                        then gosub @Ped_Tors_standart
                                        else gosub @Ped_Tors
                                        end
                                        wait Pause
                                        break
                                    end


                                    if and
                                        Ped_Select == 4 // 
                                        0E4D: random_percent 65
                                    then
                                        0085: 20@(Ped_Select,1i) = 0@ // (int)
                                        0E0B: mark_char_as_needed 20@(Ped_Select,1i)


                                        0209: 2@ = random_int_in_ranges 1 3 // random hand
                                        if 2@ == 1
                                        then 08BD: set Bit_sets bit Select_Hand
                                        else 08C3: clear Bit_sets bit Select_Hand
                                        end

                                        29@ = 0
                                        gosub @drink
                                        gosub @Ped_drink_standart
                                        wait Pause
                                        break
                                    end

                                    if and
                                        Ped_Select == 5 // 
                                        2@ >= 9
                                        2@ < 17
                                        0E4D: random_percent 2
                                    then
                                        0085: 20@(Ped_Select,1i) = 0@ // (int)
                                        0E0B: mark_char_as_needed 20@(Ped_Select,1i)
                                        gosub @Read
                                        gosub @Ped_Read
                                        wait Pause
                                        break
                                    end

                                    if and
                                        Ped_Select == 6 // 
                                        2@ >= 9
                                        2@ < 17
                                        0E4D: random_percent 10
                                    then
                                        0085: 20@(Ped_Select,1i) = 0@ // (int)
                                        0E0B: mark_char_as_needed 20@(Ped_Select,1i)
                                        30@ = 0
                                        1@ = 330
                                        gosub @Ped_Phone_Standart
                                        wait Pause
                                        break
                                    end
                                end
                            end
                            break
                        end
                    end
                end
            end
        end
    end
end
end
end
end
end


//  ,   

:Man_Case
0209: 1@ = random_int_in_ranges 1 3
if
    1@ == 1
then
    0209: 2@ = random_int_in_ranges 1 4
    2@ *= 4
    read_struct_offset 1@ iBuffer offset 2@ size 4   // Read ID of Model 2
else
    0209: 2@ = random_int_in_ranges 1 7
    if 2@ == 3
    then 0209: 2@ = random_int_in_ranges 4 7
    end
    if or
        2@ == 1
        2@ == 2
    then
        3@ = 24
    end
    2@ += 59
    2@ *= 4
    read_struct_offset 1@ iBuffer offset 2@ size 4   // Read ID of Model 2
end
return

:Woman_Shop
0209: 1@ = random_int_in_ranges 1 3
if
    1@ == 1
then
    0209: 2@ = random_int_in_ranges 5 8
    2@ += 20
    2@ *= 4
    read_struct_offset 1@ iBuffer offset 2@ size 4   // Read ID of Model 2
else
    0209: 2@ = random_int_in_ranges 3 10
    if or
        2@ == 5
        2@ == 6
        2@ == 8
    then
        2@ = 9
    end
    if 2@ == 3
    then 3@ = 24
    end
    2@ += 59
    2@ *= 4
    read_struct_offset 1@ iBuffer offset 2@ size 4   // Read ID of Model 2
end
return

:Tors
0209: 2@ = random_int_in_ranges 1 6
if and
    not 2@ == 4
    not 2@ == 5
then
    2@ += 14
    2@ *= 4
    read_struct_offset 1@ iBuffer offset 2@ size 4   // Read ID of Model 2
    2@ = 1
end
if 2@ == 4
then 1@ = 2663
end
if 2@ == 5
then
    2@ = 8
    2@ += 59
    2@ *= 4
    read_struct_offset 1@ iBuffer offset 2@ size 4   // Read ID of Model 2
end
4@ = 0.09
5@ = 0.1
6@ = 0.016
7@ = 0.0
8@ = 0.9
9@ = 0.0
return


:drink
0209: 2@ = random_int_in_ranges 6 11
4@ = 0.09
5@ = 0.025
6@ = -0.02
7@ = 180.0
8@ = 0.9
if
    2@ == 6
then
    1@ = 1455
end
if
    2@ == 7
then
    1@ = 2647
    8@ = 0.5
end
if
    2@ == 8
then
    1@ = 1486
    8@ = 0.8
end
if
    2@ == 9
then
    1@ = 2601
    8@ = 0.8
end
if
    2@ == 10
then
    1@ = 1546
    4@ = 0.08
    8@ = 0.8
end
return


:Read
0209: 2@ = random_int_in_ranges 1 4
if 2@ == 1
then
    2@ = 50
    2@ *= 4
    read_struct_offset 1@ iBuffer offset 2@ size 4   // Read ID of Model 2
    2@ = 1
    05AA: 27@s = "walk2"
end
if 2@ == 2
then
    2@ = 51
    2@ *= 4
    read_struct_offset 1@ iBuffer offset 2@ size 4   // Read ID of Model 2
    2@ = 1
    05AA: 27@s = "walk2"
end
if 2@ == 3
then
    2@ = 52
    2@ *= 4
    read_struct_offset 1@ iBuffer offset 2@ size 4   // Read ID of Model 2
    2@ = 1
    05AA: 27@s = "walk2"
end
4@ = 0.25
5@ = 0.02
6@ = 0
7@ = 0.0
9@ = -2.0
return


//  

:Ped_Phone_Standart
model.Load(1@)
if
    not model.Available(1@)
then
    repeat
    wait 0
    model.Load(1@)
    until model.Available(1@)
end
038B: load_requested_models
if
    056D:   actor 20@(Ped_Select,1i) defined
then
    0E2E: create_render_object_to_char_bone 20@(Ped_Select,1i) model 1@ bone 24 offset 0 0 0 rotation 0 0 0 store_to 10@(Ped_Select,1i)
    0E30: set_render_object_auto_hide 10@(Ped_Select,1i) dead 1 weapon 1 car 1
    0A1A: actor 20@(Ped_Select,1i) perform_walk_animation "PHONE_IN" IFP "Ped" framedelta 4.0 loopA 0 lockX 0 lockY 0 lockF 1 -1 ms // versionC
end
model.Destroy(1@)
return

:Ped_Read
0F02:  20@(Ped_Select,1i) special_model 1@ bone 24 offset 4@ 5@ 6@ rotation 0 7@ 9@ scale 10@(Ped_Select,1i) // bone 34 left hand, 24 right hand, 9 had, 3 tors
0E30: set_render_object_auto_hide 10@(Ped_Select,1i) dead 1 weapon 1 car 1
0A1A: actor 20@(Ped_Select,1i) perform_walk_animation 27@s IFP "PedEventsMod" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 0 -1 ms // versionC
return


:Ped_drink
if
    08B7:   test Bit_sets bit Select_Hand
then
    7@ = 0.0
    2@ = 24
else
    2@ = 34
end
0F02:  20@(Ped_Select,1i) special_model 1@ bone 2@ offset 4@ 5@ 6@ rotation 0 7@ 0 scale 10@(Ped_Select,1i) // bone 34 left hand, 24 right hand, 9 had, 3 tors
set_render_object_scale 10@(Ped_Select,1i) 8@ 8@ 8@
0E30: set_render_object_auto_hide 10@(Ped_Select,1i) dead 1 weapon 1 car 1
0006: TIMERA = 0
return

:Ped_drink_standart
model.Load(1@)
if
    not model.Available(1@)
then
    repeat
    wait 0
    model.Load(1@)
    until model.Available(1@)
end
038B: load_requested_models
if
    08B7:   test Bit_sets bit Select_Hand
then
    7@ = 0.0
    2@ = 24
else
    2@ = 34
end
if
    056D:   actor 20@(Ped_Select,1i) defined
then
    0E2E: create_render_object_to_char_bone 20@(Ped_Select,1i) model 1@ bone 2@ offset 4@ 5@ 6@ rotation 0 7@ 0 store_to 10@(Ped_Select,1i)
    set_render_object_scale 10@(Ped_Select,1i) 8@ 8@ 8@
    0E30: set_render_object_auto_hide 10@(Ped_Select,1i) dead 1 weapon 1 car 1
    0006: TIMERA = 0
end
model.Destroy(1@)
return


:Ped_Tors
0F02:  20@(Ped_Select,1i) special_model 1@ bone 24 offset 4@ 5@ 6@ rotation 0 7@ 9@ scale 10@(Ped_Select,1i) // bone 34 left hand, 24 right hand, 9 had, 3 tors
set_render_object_scale 10@(Ped_Select,1i) 8@ 8@ 8@
0E30: set_render_object_auto_hide 10@(Ped_Select,1i) dead 1 weapon 1 car 1
0A1A: actor 20@(Ped_Select,1i) perform_walk_animation "walk1" IFP "PedEventsMod" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 0 -1 ms // versionC
return

:Ped_Tors_standart
model.Load(1@)
if
    not model.Available(1@)
then
    repeat
    wait 0
    model.Load(1@)
    until model.Available(1@)
end
038B: load_requested_models
if
    056D:   actor 20@(Ped_Select,1i) defined
then
    0E2E: create_render_object_to_char_bone 20@(Ped_Select,1i) model 1@ bone 24 offset 4@ 5@ 6@ rotation 0 7@ 9@ store_to 10@(Ped_Select,1i)
    set_render_object_scale 10@(Ped_Select,1i) 8@ 8@ 8@
    0E30: set_render_object_auto_hide 10@(Ped_Select,1i) dead 1 weapon 1 car 1
    0A1A: actor 20@(Ped_Select,1i) perform_walk_animation "walk1" IFP "PedEventsMod" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 0 -1 ms // versionC
end
model.Destroy(1@)
return


:Ped_case
0F02:  20@(Ped_Select,1i) special_model 1@ bone 3@ offset 0 0 0 rotation 0 0 0 scale 10@(Ped_Select,1i) // bone 34 left hand, 24 right hand, 9 had, 3 tors
0E30: set_render_object_auto_hide 10@(Ped_Select,1i) dead 1 weapon 1 car 1
wait 200
return

:Ped_case_standart
model.Load(1@)
if
    not model.Available(1@)
then
    repeat
    wait 0
    model.Load(1@)
    until model.Available(1@)
end
038B: load_requested_models
if
    056D:   actor 20@(Ped_Select,1i) defined
then
    0E2E: create_render_object_to_char_bone 20@(Ped_Select,1i) model 1@ bone 3@ offset 4@ 5@ 6@ rotation 0 7@ 0 store_to 10@(Ped_Select,1i)
    set_render_object_scale 10@(Ped_Select,1i) 8@ 8@ 8@
    0E30: set_render_object_auto_hide 10@(Ped_Select,1i) dead 1 weapon 1 car 1
end
model.Destroy(1@)
return



//   


:Ped_20
for Ped_Select = 0 to Number_Peds step 1
wait 10
if
    056D: actor 20@(Ped_Select,1i) defined
then
    0A96: 3@ = ped 20@(Ped_Select,1i) struct
    0D4E: 2@ = read_struct 3@ offset 0x470 size 1
    if 08B7:   test 2@ bit 3 //      
    then
        08C3: clear 2@ bit 3
        0E28: write_struct 3@ offset 0x470 size 1 value 2@ //      
        10@(Ped_Select,1i) = -1
        gosub @PedsMod_Delete_Render
        continue
    end
    if and
        not actor.Dead(20@(Ped_Select,1i))
        is_char_script_controlled 20@(Ped_Select,1i)
        locate_char_distance_to_char 20@(Ped_Select,1i) char $PLAYER_ACTOR radius 120.0
    then
            //    
            if
                Ped_Select == 3
            then
                0EFF: get_char_simplest_active_task 20@(Ped_Select,1i) id_to 3@ pointer_to 2@
                if and
                    02CB:   actor 20@(Ped_Select,1i) bounding_sphere_visible
                    3@ == 900
                    not 3@ == 401
                    not Actor.Animation(20@(Ped_Select,1i)) == "walk1"
                    timerb > 5000
                then
                    0A1A: actor 20@(Ped_Select,1i) perform_walk_animation "walk1" IFP "PedEventsMod" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 0 -1 ms // versionC
                    timerb = 0
                end
            end

            // 
            if
                Ped_Select == 4
            then
                0EFF: get_char_simplest_active_task 20@(Ped_Select,1i) id_to 3@ pointer_to 2@
                if and
                    02CB:   actor 20@(Ped_Select,1i) bounding_sphere_visible
                    3@ == 900
                    0019:   TIMERA > 15000
                then
                    if
                        08B7:   test Bit_sets bit Select_Hand
                    then
                        0A1A: actor 20@(Ped_Select,1i) perform_walk_animation "DRNKBR_PRTL" IFP "GANGS" framedelta 4.0 loopA 0 lockX 0 lockY 0 lockF 0 -1 ms // versionC
                        0006: TIMERA = 0
                        29@ += 1
                    else
                        0A1A: actor 20@(Ped_Select,1i) perform_walk_animation "vend_drink2_p" IFP "vending" framedelta 4.0 loopA 0 lockX 0 lockY 0 lockF 0 -1 ms // versionC
                        0006: TIMERA = 0
                        29@ += 1
                    end
                end
                if and
                    timerb > 3000
                    29@ >= 5
                then
                    gosub @PedsMod_Delete_Render
                    continue
                end
            end

            // 
            if
                Ped_Select == 5
            then
                0EFF: get_char_simplest_active_task 20@(Ped_Select,1i) id_to 3@ pointer_to 2@
                0D59: get_current_weather_to 2@
                if or
                    2@ == 8 // weather rain
                    2@ == 16 // weather rain 2
                then
                    if and
                        02CB:   actor 20@(Ped_Select,1i) bounding_sphere_visible
                        3@ == 900
                        not Actor.Animation(20@(Ped_Select,1i)) == "RainPaper"
                        timerb > 5000
                        not Actor.Animation(20@(Ped_Select,1i)) == "sprint_panic"
                        not Actor.Animation(20@(Ped_Select,1i)) == "woman_runpanic"
                    then
                        0A1A: actor 20@(Ped_Select,1i) perform_walk_animation "RainPaper" IFP "PedEventsMod" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 0 -1 ms // versionC
                        timerb = 0
                    end
                end
                if
                    not Actor.Animation(20@(Ped_Select,1i)) == 27@s
                then
                    if and
                        02CB:   actor 20@(Ped_Select,1i) bounding_sphere_visible
                        not 2@ == 8 // weather rain
                        not 2@ == 16 // weather rain 2
                        3@ == 900
                        timerb > 5000
                        not Actor.Animation(20@(Ped_Select,1i)) == "sprint_panic"
                        not Actor.Animation(20@(Ped_Select,1i)) == "woman_runpanic"
                    then
                        0A1A: actor 20@(Ped_Select,1i) perform_walk_animation 27@s IFP "PedEventsMod" framedelta 4.0 loopA 1 lockX 0 lockY 0 lockF 0 -1 ms // versionC
                        timerb = 0
                    end
                end
                if or
                    Actor.Animation(20@(Ped_Select,1i)) == "sprint_panic"
                    Actor.Animation(20@(Ped_Select,1i)) == "woman_runpanic"
                then
                    if
                        Actor.Animation(20@(Ped_Select,1i)) == 27@s
                    then
                        0E97: clear_char_secondary_tasks 20@(Ped_Select,1i)
                    end
                end
            end

            // 
            if
                Ped_Select == 6
            then
                0D59: get_current_weather_to 2@
                if or
                    2@ == 8 // weather rain
                    2@ == 16 // weather rain 2
                then
                    gosub @PedsMod_Delete_Render
                    continue
                end
                0EFF: get_char_simplest_active_task 20@(Ped_Select,1i) id_to 3@ pointer_to 2@
                if
                    not Actor.Animation(20@(Ped_Select,1i)) == "PHONE_IN"
                then
                    if and
                        02CB:   actor 20@(Ped_Select,1i) bounding_sphere_visible
                        not 3@ == 401
                        not Actor.Animation(20@(Ped_Select,1i)) == "idle_chat"
                        3@ == 900
                        timerb > 5000
                    then
                        0A1A: actor 20@(Ped_Select,1i) perform_walk_animation "PHONE_IN" IFP "Ped" framedelta 4.0 loopA 0 lockX 0 lockY 0 lockF 1 -1 ms // versionC
                        timerb = 0
                    end
                end
                if and
                    Actor.Animation(20@(Ped_Select,1i)) == "PHONE_IN"
                    3@ == 900 //walk
                    0019:   TIMERB > 10000
                then
                    30@ += 1
                    0209: 2@ = random_int_in_ranges 1 3
                    if 2@ == 1
                    then 05C1: AS_actor 20@(Ped_Select,1i) speak_from_audio_table 118
                    end
                    if 2@ == 2
                    then 05C1: AS_actor 20@(Ped_Select,1i) speak_from_audio_table 166
                    end
                    timerb = 0
                end
                if and
                    02CB:   actor 20@(Ped_Select,1i) bounding_sphere_visible
                    0019:   TIMERB > 3000
                    30@ >= 7
                then
                    0A1A: actor 20@(Ped_Select,1i) perform_walk_animation "PHONE_OUT" IFP "PED" framedelta 4.0 loopA 0 lockX 0 lockY 0 lockF 0 -1 ms // versionC
                    timerb = 0
                    gosub @PedsMod_Delete_Render
                    continue
                end
            end

            080E: get_actor 20@(Ped_Select,1i) ped_event_to 1@
            if or
                1@ == 49 // shoot close ped
                0E47: is_char_fighting 20@(Ped_Select,1i)
                actor.Driving(20@(Ped_Select,1i))
                82D8:   not actor 20@(Ped_Select,1i) current_weapon == 0
            then
                gosub @PedsMod_Delete_Render
            end
        else
            gosub @PedsMod_Delete_Render
        end
    end
end
return


//      
:PedsMod_Delete_Render
if
    056D: actor 20@(Ped_Select,1i) defined
then
    if
        not locate_char_distance_to_char 20@(Ped_Select,1i) char $PLAYER_ACTOR radius 50.0
    then
        if
            0E0A: is_char_script_controlled 20@(Ped_Select,1i)
        then
            01C2: remove_references_to_actor 20@(Ped_Select,1i) // Like turning an actor into a random pedestrian
        end
    else
        if
            0E0A: is_char_script_controlled 20@(Ped_Select,1i)
        then
            if
                not 10@(Ped_Select,1i) <= -1
            then
                0E31: set_render_object_visible 10@(Ped_Select,1i) 0
            end
            if
                not actor.Dead(20@(Ped_Select,1i))
            then
                if
                    Ped_Select >= 3
                then
                    0E97: clear_char_secondary_tasks 20@(Ped_Select,1i)
                end
            end
            01C2: remove_references_to_actor 20@(Ped_Select,1i) // Like turning an actor into a random pedestrian
        end
    end
end
20@(Ped_Select,1i) = -1
10@(Ped_Select,1i) = -1
return

//  
:Load_animation
if or
    84EE: not animation "PedEventsMod" loaded
    84EE: not animation "VENDING" loaded
    84EE: not animation "GANGS" loaded
then
    repeat
    wait 0
    04ED: load_animation  "PedEventsMod"
    04ED: load_animation  "VENDING"
    04ED: load_animation  "GANGS"
        if and
            04EE: animation "PedEventsMod" loaded
            04EE: animation "VENDING" loaded
            04EE: animation "GANGS" loaded
        then
            break
        end
    until not player.Defined(0)
end
return


:Ped_skin
Ped_skin = false
if or
    02F2:   actor 0@ model == 128 // Farm Inhabitant
    02F2:   actor 0@ model == 129 // Farm Inhabitant
    02F2:   actor 0@ model == 130 // Farm Inhabitant
    02F2:   actor 0@ model == 131 // Farm Inhabitant
    02F2:   actor 0@ model == 132 // Farm Inhabitant
    02F2:   actor 0@ model == 133 // Farm Inhabitant
    02F2:   actor 0@ model == 158 // Farmer
then
    Ped_skin = true
end
if or
    02F2:   actor 0@ model == 161 // Farmer
    02F2:   actor 0@ model == 201 // Farmer
    02F2:   actor 0@ model == 202 // Farmer
    02F2:   actor 0@ model == 157 // Hillbilly
    02F2:   actor 0@ model == 159 // Hillbilly
    02F2:   actor 0@ model == 160 // Hillbilly
    02F2:   actor 0@ model == 162 // Hillbilly
then
    Ped_skin = true
end
if or
    02F2:   actor 0@ model == 197 // Hillbilly
    02F2:   actor 0@ model == 200 // Hillbilly
    02F2:   actor 0@ model == 31 // Farm-Town inhabitant
    02F2:   actor 0@ model == 32 // Farm-Town inhabitant
    02F2:   actor 0@ model == 33 // Farm-Town inhabitant
    02F2:   actor 0@ model == 34 // Farm-Town inhabitant
    02F2:   actor 0@ model == 196 // Farm-Town inhabitant
then
    Ped_skin = true
end
if or
02F2:   actor 0@ model == 198 // Farm-Town inhabitant
02F2:   actor 0@ model == 199 // Farm-Town inhabitant
02F2:   actor 0@ model == 33 // Farm-Town inhabitant
02F2:   actor 0@ model == 34 // Farm-Town inhabitant
02F2:   actor 0@ model == 196 // Farm-Town inhabitant
then
    Ped_skin = true
end
return


//     
:References_remove
for Ped_Select = 0 to Number_Peds step 1
    if
        056D:   actor 20@(Ped_Select,1i) defined
    then
        01C2: remove_references_to_actor 20@(Ped_Select,1i) // Like turning an actor into a random pedestrian
        20@(Ped_Select,1i) = -1
        10@(Ped_Select,1i) = -1
    end
end
return

//      ,   
:Realese_animation
if and
    856D: not actor 20@ defined
    856D: not actor 21@ defined
    856D: not actor 22@ defined
    856D: not actor 23@ defined
    856D: not actor 24@ defined
    856D: not actor 25@ defined
    856D: not actor 26@ defined
then
    if and
        04EE: animation "PedEventsMod" loaded
        04EE: animation "VENDING" loaded
        04EE: animation "GANGS" loaded
    then
        04EF: release_animation "PedEventsMod"
        04EF: release_animation "GANGS"
        04EF: release_animation "VENDING"
    end
    0842: 2@ = player $PLAYER_CHAR town_number
    0D59: get_current_weather_to 1@
    if or
        1@ == 8 // not weather rain
        1@ == 16 // not weather rain 2
        not 2@ == 0
        not $ACTIVE_INTERIOR == 0
    then
        0A93: terminate_this_custom_script
    end
end
return
